#include <cstdio>
#include <iostream>
#define LL long long
#define IN inline
#define re register
using namespace std;
IN LL read() {
	LL res = 0; char ch = getchar();
	for(; !isdigit(ch); ch = getchar());
	for(; isdigit(ch); ch = getchar()) res = (res << 3) + (res << 1) + (ch ^ 48);
	return res;
}
LL n, l, r, ans, len;
int main() {
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	n = read(), l = read(), r = read();
	ans = l % n;
	len = r - l;
	if(ans + len >= n) printf("%lld\n",n - 1);
	else printf("%lld\n",(ans + len) % n);
	return 0;
}
